/**
 * 弹出登录框
 */
login_panel = function(){
	 var userLoginPanel = Ext.create('Ext.Panel', {  
	 		bodyStyle: 'background:url(lib/img/logo.png ) no-repeat top;',
	        border : false,  
	        defaults:{  
	            margin:'64 0'  
	        },  
	        items:{  
	            xtype : 'tabpanel',  
	            id : 'loginTabs',  
	            activeTab : 0,  
	            height : 180,  
	            border : false,  
	            items:[{  
	                title : "用户登录",  
	                xtype : 'form',  
	                id : 'loginForm',  
	                defaults : {  
	                    width : 260,  
	                    margin: '10 0 0 70'  
	                },  
	                // The fields  
	                defaultType : 'textfield',  
	                labelWidth : 40,  
	                items: [{  
	                    fieldLabel: '用户账户',  
	                    cls : 'user',  
	                    name: 'username',  
	                    labelAlign:'right',  
	                    labelWidth:65,  
	                    maxLength : 30,  
	                    emptyText:'请在这里填写用户名',  
	                    maxLengthText : '账号的最大长度为30个字符',  
	                    blankText:"用户名不能为空，请填写！",//错误提示信息，默认为This field is required!  
	                    allowBlank: false  
	                },{  
	                    fieldLabel: '登录密码',  
	                    cls : 'key',  
	                    name: 'password',  
	                    inputType:"password",  
	                    labelWidth:65,  
	                    labelAlign:'right',  
	                    emptyText:'请在这里填写密码',  
	                    maxLengthText :'密码长度不能超过20',  
	                    maxLength : 20,  
	                    blankText:"密码不能为空，请填写！",//错误提示信息，默认为This field is required!  
	                    allowBlank: false  
	                }/*,{  
	                    xtype:"combo",  
	                    fieldLabel: '登录角色',  
	                    cls : 'Userkey',  
	                    name: 'role',  
	                    labelAlign:'right',  
	                    labelWidth:65,  
	                    store:["配方工程师","系统管理员","厂长","总经理"],//数据源为一数组  
	                    emptyText:'请选择角色.',  
	                    blankText:"请选择角色！",//错误提示信息，默认为This field is required!  
	                    allowBlank: false  
	                }  */, {  
	                    id : 'id_reg_panel',  
	                    xtype : 'panel',  
	                    border : false,  
	                    hidden : true,  
	                    html : '<span id="messageTip" style="color:red"></span>'  
	                }]  
	            }/* , {  
	                title : '关于',
	                html  : "text",
	               // contentEl : 'aboutDiv',  
	                defaults : {  
	                    width : 230  
	                }  
	            } */]  
	        }  
	    });  
	      
	 Ext.create('Ext.Window', {  
	        title : 'mes',  
	        width : 440,  
	        height : 320,  
	        layout: 'fit',  
	        id:	  "userlogin",
	        plain : true,  
	        //modal : true,  是否遮罩
	        maximizable : false,  
	        //draggable : false,  
	        closable : false,  
	        resizable : false,  
	        items: userLoginPanel,  
	        //重置 和 登录 按钮.  
	        buttons: [{  
	            text: '重置',  
	            icon:"lib/ext/shared/icons/fam/table_refresh.png", 
	            handler: function() {  
	            	Ext.getCmp("loginForm").reset();
	                //Ext.Msg.alert('提示', '重置！');  
	            	Ext.getCmp("loginForm").getForm().setValues({"username":123,"password":123});;
	            }  
	        }, {  
	            text: '登录',  
	            icon:"lib/ext/shared/icons/fam/user.gif", 
	            handler: function() {
	            	//var data = loadData("action/UserAction.login",Ext.getCmp("loginForm").getValues()).data;
	            	/*var odbcData= {
            			"sp":"sp_user_login",
            			"parameter":[Ext.getCmp("loginForm").getValues().username,Ext.getCmp("loginForm").getValues().password],
            			"keys":["msg","users","role","menu"],
            		}; 
	                var dta = loadData("action/Action.call",odbcData);
	                sys = dta.data;*/
	            	//log(data);
	            	var datas = loadData("action/Action.listByPage",{
	            		"model"			:"Users",
	            		"start"			:0,
	            		"result"		:1,
	            		key				:"username",
	            		value			:Ext.getCmp("loginForm").getValues().username
	            	}).data;
	            	if(datas.list.length==0){
	            		Ext.Msg.alert("错误提示","用户密码或账户错误！");
	            	}else{
	            		if(datas.list[0].password==Ext.getCmp("loginForm").getValues().password){
	            			Ext.getCmp("userlogin").close();
	            			$("body").append('<div id="top_div" style="background-color:#fff;height: 58px;font-size: 20px;"><div style="float:right;margin-top: 18px;margin-right: 50px;"  ><a id="usernameDIV" href="#">哈哈</a></div><img style="float:right;margin-top: 19px; margin-right: 5px;" alt="" src="ext/shared/icons/fam/user.gif"><div style="float:right;margin-top: 18px;margin-right: 10px;"  >crm</div><div style="background:url(css/img/logo.jpg ) no-repeat;background-position:8px 8px;height: 50px;"></div></div>')
	            			//log(datas.list[0]);
	            			_('admin.panel')(datas.list[0])
	            		}else{
	            			Ext.Msg.alert("错误提示","用户密码或账户错误！");
	            		}
	            	}
	            
	            	/*if(dta!=undefined&&dta.data!=null){
	            		//log(dta);
	            		Ext.getCmp("userlogin").close();
	            		$("body").append('<div id="top_div" style="background-color:#eee;height: 58px;font-size: 20px;"><div style="float:right;margin-top: 18px;margin-right: 50px;"  ><a id="usernameDIV" href="#">哈哈</a></div><img style="float:right;margin-top: 19px; margin-right: 5px;" alt="" src="ext/shared/icons/fam/user.gif"><div style="float:right;margin-top: 18px;margin-right: 10px;"  >Planck System</div><div style="background:url(css/img/logo.png ) no-repeat;background-position:8px 8px;height: 50px;"></div></div>')
	            		_('admin.panel')(dta.data)
	            	}*/
	            }  
	        }]  
	    }).show();   
	    
}